home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
414_01
/
commsos.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-21
|
44KB
|
1,479 lines
/***********************************************************************/
/* COMMSOS.C - sos commands. */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1993 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling email: M.Hessling@gu.edu.au
* 36 David Road Phone: +61 7 849 7731
* Holland Park Fax: +61 7 875 5314
* QLD 4121
* Australia
*/
/*
$Header: C:\THE\RCS\commsos.c 1.4 1993/09/01 16:25:56 MH Interim MH $
*/
#include <stdio.h>
#include "the.h"
#include "proto.h"
/*#define DEBUG 1*/
/*man-start*********************************************************************
========================================================================
SOS COMMAND REFERENCE
========================================================================
**man-end**********************************************************************/
/*-------------------------- external data ----------------------------*/
extern LINE *first_command,*current_command,*last_command;
extern LINE *next_line,*curr_line;
extern VIEW_DETAILS *vd_current,*vd_first;
extern char current_screen;
extern SCREEN_DETAILS screen[MAX_SCREENS]; /* screen structures */
extern char current_file; /* pointer to current file */
extern WINDOW *foot,*error_window;
extern bool error_on_screen;
extern char *rec;
extern unsigned short rec_len;
extern char *cmd_rec;
extern unsigned short cmd_rec_len;
extern char *pre_rec;
extern unsigned short pre_rec_len;
extern char mode_insert; /* defines insert mode toggle */
extern char in_profile; /* indicates if processing profile */
extern unsigned short file_start;
extern char *temp_cmd;
extern char dir_filename[10];
extern char dir_pathname[MAX_FILE_NAME+1];
extern char sp_path[MAX_FILE_NAME+1] ;
extern char sp_fname[MAX_FILE_NAME+1] ;
extern char dir_path[MAX_FILE_NAME+1] ; /* for dir and ls commands */
extern bool prefix_changed;
/*man-start*********************************************************************
COMMAND
SOS ADDline - add blank line after focus line
SOS LINEAdd - add blank line after focus line
SYNTAX
** effective only if bound to a key **
DESCRIPTION
The SOS ADDLINE command inserts a blank line in the file following
the focus line. The cursor is placed in the column under the first
non-blank in the focus line.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
SOS DELLINE
STATUS
Complete
**man-end**********************************************************************/
#ifdef PROTO
int Sos_addline(char *params)
#else
int Sos_addline(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("commsos.c: Sos_addline");
#endif
rc = Add("1");
#ifdef TRACE
trace_return();
#endif
return(rc);
}
/*man-start*********************************************************************
COMMAND
SOS CURSORAdj - move first non-blank character to cursor
SYNTAX
** effective only if bound to a key **
DESCRIPTION
The SOS CURSORADJ command moves text in the focus line so that
the first non-blank character appears under the cursor position.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible.
STATUS
Complete
**man-end**********************************************************************/
#ifdef PROTO
int Sos_cursoradj(char *params)
#else
int Sos_cursoradj(params)
char *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short num_cols,first_non_blank_col,col,rc;
unsigned short x,y;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("commsos.c: Sos_cursoradj");
#endif
getyx(CURRENT_WINDOW,y,x);
switch (CURRENT_VIEW->current_window)
{
case WINDOW_MAIN:
if (FOCUS_TOF || FOCUS_BOF)
{
display_error(38,(char *)"");
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_ENVIRON);
}
col = x + CURRENT_VIEW->verify_col - 1;
first_non_blank_col = strzne(rec,' ');
if (first_non_blank_col == (-1))
first_non_blank_col = 0;
num_cols = first_non_blank_col - col;
if (num_cols < 0)
rc = execute_shift_command(FALSE,-num_cols,CURRENT_VIEW->focus_line,1);
else
if (num_cols > 0)
rc = execute_shift_command(TRUE,num_cols,CURRENT_VIEW->focus_line,1);
break;
default:
break;
}
#ifdef TRACE
trace_return();
#endif
return(rc);
}
/*man-start*********************************************************************
COMMAND
SOS DELBAck - delete the character to the left of the cursor
SYNTAX
** effective only if bound to a key **
DESCRIPTION
The SOS DELBACK command moves the cursor one character to the left
and deletes the character now under the cursor.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible.
SEE ALSO
SOS DELCHAR
STATUS
Complete
**man-end**********************************************************************/
#ifdef PROTO
int Sos_delback(char *params)
#else
int Sos_delback(params)
char *params;
#endif
/***********************************************************************/
{
/*------------------------- external data -----------------------------*/
extern bool extended_display_mode;
extern bool CMDARROWSTABLRx;
/*--------------------------- local data ------------------------------*/
unsigned short x,y;
bool save_CMDARROWSTABLRx = CMDARROWSTABLRx;
/*--------------------------- processing ------------------------------*/
#ifdef TRACE
trace_function("commsos.c: Sos_delback");
#endif
getyx(CURRENT_WINDOW,y,x);
switch (CURRENT_VIEW->current_window)
{
case WINDOW_MAIN:
if (FOCUS_TOF || FOCUS_BOF)
{
display_error(38,(char *)"");
#ifdef TRACE
trace_return();
#endif
return(RC_INVALID_ENVIRON);
}
break;
case WINDOW_COMMAND:
if (x == 0)
{
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
}
mvwdelch(CURRENT_WINDOW,y,x-1);
if (x <= cmd_rec_len)
{
cmd_rec = (char *)memdelchr((char *)cmd_rec,
x-1,cmd_rec_len,1);
cmd_rec_len--;
}
#ifdef TRACE
trace_return();
#endif
return(RC_OK);
break;
case WINDOW_PREFIX:
if (x == 0)
{
#ifdef TRACE
trace_return();
#endif
return(RC_OK);